package com.sqfw.project.zj.controller;

import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.framework.web.page.TableDataInfo;
import com.sqfw.project.zj.domain.ZjRecord;
import com.sqfw.project.zj.service.IZjRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 录音信息Controller
 *
 * @author lx
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/zj/zjRecord/")
public class ZjRecordController extends BaseController
{
    @Autowired
    private IZjRecordService zjRecordService;

    /**
     * 查询录音信息列表
     */
    @PreAuthorize("@ss.hasPermi('zj:zjRecord')")
    @GetMapping("/list")
    public TableDataInfo list(ZjRecord zjRecord)
    {
        startPage();
        List<ZjRecord> list = zjRecordService.selectZjRecordList(zjRecord);
        return getDataTable(list);
    }

    /**
     * 导出录音信息列表
     */
    @Log(title = "录音信息", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('zj:zjRecord')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjRecord zjRecord)
    {
        List<ZjRecord> list = zjRecordService.selectZjRecordList(zjRecord);
        ExcelUtil<ZjRecord> util = new ExcelUtil<ZjRecord>(ZjRecord.class);
        util.exportExcel(response, list, "录音信息数据");
    }

    /**
     * 获取录音信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('zj:zjRecord')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") String recordId)
    {
        return success(zjRecordService.selectZjRecordByRecordId(recordId));
    }

    /**
     * 新增录音信息
     */
    @PreAuthorize("@ss.hasPermi('zj:zjRecord')")
    @PostMapping
    public AjaxResult add(@RequestBody ZjRecord zjRecord){
        return toAjax(zjRecordService.insertZjRecord(zjRecord));
    }

    /**
     * 修改录音信息
     */
    @PreAuthorize("@ss.hasPermi('zj:zjRecord')")
    @PostMapping("/handleZjRecord")
    public AjaxResult edit(@RequestBody ZjRecord zjRecord){
        return toAjax(zjRecordService.updateZjRecord(zjRecord));
    }

    /**
     * 删除录音信息
     */
    @PreAuthorize("@ss.hasPermi('zj:zjRecord')")
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable String[] recordIds)
    {
        return toAjax(zjRecordService.deleteZjRecordByRecordIds(recordIds));
    }
}
